package com.anbei.demo.sc.discorery;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 1.注意和ZK版本：server+client(discovery)一致
 * 2.依赖参考：https://cloud.spring.io/spring-cloud-zookeeper/reference/html/#spring-cloud-zookeeper-discovery
 * 3.不更改依赖报错
 *
 * 4.https://v.douyu.com/show/jwzOvpw83XxWZVRm
 *  1.各种注册中心对比
 *  2.zk例子
 *
 */
@SpringBootApplication
@RestController
@EnableDiscoveryClient
public class ZKClientApplication {

    public static void main(String[] args) {
        SpringApplication.run( ZKClientApplication.class, args );
    }

    @Value("${server.port}")
    String port;

    /**
     * 注册节点里没有http，怎么调用呢？
     *
     * node:services--application.name-instance-id(node.data)
     * @param name
     * @return
     */
    @RequestMapping("/hi")
    public String home(@RequestParam(value = "name", defaultValue = "forezp") String name) {
        return "hi " + name + " ,i am from port:" + port;
    }

}



